﻿using System;

class Solution2
{
    static void Main()
    {
        string[] pleasantnessStrArr = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None);

        int[] pleasantness = new int[pleasantnessStrArr.Length];


        int variaty = int.Parse(Console.ReadLine());


        for (int i = 0; i < pleasantnessStrArr.Length; i++)
        {
            pleasantness[i] = int.Parse(pleasantnessStrArr[i]);
        }



        int indexMin = 0;
        int indexMax = 0;
        int index = 0;
        int totalDistance = 100;
        
        while (index < pleasantness.Length)
        {
            int difference = pleasantness[index] - variaty;
            if (difference >= 0)
            {
                int innerIndex = 0;
                bool match = false;

                while ((innerIndex < pleasantness.Length) && !match)
                {
                    if (pleasantness[innerIndex] <= difference)
                    {
                        match = true;

                        if (totalDistance > (index + innerIndex))
                        {
                            indexMax = index;
                            indexMin = innerIndex;
                            totalDistance = index + innerIndex;
                        }
                    }
                    innerIndex++;
                }
            }

            index++;
        }

        if (pleasantness[indexMax] - pleasantness[indexMin] < variaty)
        {
            Console.WriteLine(pleasantness.Length);
        }
        else
        {
            int smallerIndex;
            int biggerIndex;

            if (indexMin < indexMax)
            {
                smallerIndex = indexMin;
                biggerIndex = indexMax;
            }
            else
            {
                smallerIndex = indexMax;
                biggerIndex = indexMin;
            }

            int count = smallerIndex / 2 + smallerIndex % 2 + 1;
            smallerIndex = biggerIndex - smallerIndex;
            count += smallerIndex / 2 + smallerIndex % 2;

            Console.WriteLine(count);
        }
    }
}
